package wqh.modbus;

import cn.tpson.sewercover.core.ISewerCoverDataCallBack;
import cn.tpson.sewercover.core.SewerCoverManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import wqh.domain.DtDevice;
import wqh.global.GlobalDevice;
import wqh.global.GlobalTime;
import wqh.service.DtDeviceService;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.util.List;
/**
 * Created by cfs on 2016/12/23.
 */
public class DtModBusServlet extends HttpServlet{
    @Override
    public void destroy(){
        super.destroy();
        SewerCoverManager.getInstance().stopServer();

    }

    public void init(ServletConfig config) throws ServletException{
        super.init(config);
        System.out.println("SewerCoverManager启动");
        ApplicationContext ac = new FileSystemXmlApplicationContext("classpath:/spring/springmvc-dispatcher.xml");
        DtDataCallBack dtDataCallBack = (DtDataCallBack)ac.getBean("dtDataCallBack");//这里有问题
        SewerCoverManager.getInstance().setCallback(dtDataCallBack);
        SewerCoverManager.getInstance().startServer();
    }
}
